<%@page import="Business.Comment"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="java.util.Iterator"%>


<%@page import="Business.Product"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="WEB-INF/jspf/header.jspf" %>
<script type="text/javascript">
    function clearTextArea() {
        document.getElementById("comment").value=" ";
    }
</script>

<%
            request.setCharacterEncoding("utf-8");
            Product product = (Product) request.getAttribute("product");
            ArrayList<Comment> comments = (ArrayList<Comment>) request.getAttribute("comments");
            int quantity = ((Integer) request.getAttribute("quantity")).intValue();
            String status = "Hết hàng";
            if (quantity >= 0) {
                status = "Còn hàng";
            }
            String description = "";
            if (product.getDescription() != null) {
                description = product.getDescription();
            }
            NumberFormat nf = NumberFormat.getInstance();
            //nf.setMinimumFractionDigits(2);
            nf.setMaximumFractionDigits(2);
            

%>


            <div class="borderheader"><%=product.getProductCode()%><br></div>
<table width="125" border="0">
    <tr>
        <td height="162"><table width="600" border="0">
                <tr>
                    <td height="144"><img src ="<%=product.getImage()%>" alt="<%=product.getProductCode()%>" width="244" height="150"></td>
                    <td>
                        <div style="width: 210px;">
                            <div class="pro_name_more"><%=product.getVendor() + " " + product.getProductCode()%></div>
                            <div class="pro_nd_more"></div>
                            <div class="pro_nd_more">Nhà sản xuất: <strong><%=product.getVendor()%></strong><br>
                                Thời gian bảo hành : <strong><%=product.getWarranty()%> THÁNG</strong></div>
                            <div style="height: 10px"></div>
                            <div class="line_comment"></div>
                            <div style="height: 10px"></div>
                            <div class="pro_nd_more">
                                <strong>Giá: <span class="pro_price"><%=nf.format(product.getPrice())%> VNĐ</span></strong></div>
                            <div class="pro_nd_more">
                                &nbsp;</div>
                            <div>
                                <form action="cart" method="post">
                                    <input type="hidden" name="productCode" value="<%=product.getProductCode()%>">
                                    <input type="image" src="images/design/button_buy.jpg" width="95" height="24" alt="Mua hàng">
                                    <!-- AddThis Button BEGIN -->
                               <div class="addthis_toolbox addthis_default_style ">
                                   <div><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
                                       <a class="addthis_button_tweet"></a></div>
                                   <div>
                                       <a class="addthis_button_google_plusone" g:plusone:size="large"></a>
                                       <a class="addthis_counter addthis_pill_style"></a></div>
                                       <a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
                               </div>
                   <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f826725343d34ec"></script>
                                    <!-- AddThis Button END -->
                                </form>
                            </div>

                        </div>
                    </td>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td height="316"><table width="598" border="1">
                <caption>
                    <strong>Thông Tin Chi Tiết     </strong>
                </caption>
                <tr>
                    <td width="30%">CPU</td>
                    <td width="70%"><%=product.getCpu()%></td>
                </tr>
                <tr>
                    <td>HDD</td>
                    <td><%=product.getHdd()%></td>
                </tr>
                <tr>
                    <td>Ram</td>
                    <td><%=product.getRam()%></td>
                </tr>
                <tr>
                    <td>Card Màn Hình(VGA)</td>
                    <td><%=product.getCardmonitor()%></td>
                </tr>
                <tr>
                    <td>Màn Hình(Display)</td>
                    <td><%=product.getDisplay()%></td>
                </tr>
                <tr>
                    <td>Weight/Height</td>
                    <td><%=product.getWeightheight()%></td>
                </tr>
                <tr>
                    <td>Modem/NIC</td>
                    <td><%=product.getLanwirelessbluetooth()%></td>
                </tr>
                <tr>
                    <td>DVD-WL</td>
                    <td><%=product.getDVDWL()%></td>
                </tr>
                <tr>
                    <td>Hệ Điều Hành</td>
                    <td><%= product.getOS()%></td>
                </tr>
                <tr>
                    <td>Battery</td>
                    <td><%=product.getBattery()%></td>
                </tr>
                <tr>
                    <td>Bảo Hành</td>
                    <td><%=product.getWarranty()%>Tháng</td>
                </tr>
                <tr>
                    <td>Mô tả</td>
                    <td><%=description%></td>
                </tr>
                <tr>
                    <td>Tình Trạng</td>
                    <td><%=status%></td>
                </tr>

            </table></td>
    </tr>
    <tr>

        <td height="188"><table width="600" border="1"><caption align="left">
                    <em><strong>Ý Kiến Bạn Đọc</strong></em>
                </caption>

                <%
                            for (Comment comm : comments) {

                %>
                <tr>

                    <td width="82" height="104"><%=comm.getUsername()%></td>
                    <td width="600"><%=comm.getComment()%></td>

                </tr>
                <% }%>
            </table>

            <form id="commentForm" name="commentForm" method="post" action="CommentServlet">
                <div class="nd_comment">
                    <input type="hidden" name="productCode" value="<%=product.getProductCode()%>">
                    <textarea  onclick="clearTextArea()"id ="comment"name="comment" cols="1" rows="5" style="width:400px; border:1px solid #b3b3b3;">Nội dung bình luận ...</textarea><br />
                </div><br>

                <input  type="image" src="images/design/butt_comment.jpg" width="95" height="24" alt="">
            </form>
        </td>
    </tr>
</table>
<%@include file="WEB-INF/jspf/footer.jspf" %>